﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_STL_Core.h".
//-------------------------------------------------------------------

#ifndef _UXS_MATH_TYPES_H
#define _UXS_MATH_TYPES_H

#pragma once

#include "../BaseTypes/TFixed.h"
#include "../BaseTypes/TFloat.h"
#include "../CompileTime/TTypeInfo.h"

namespace UX_STL
{
namespace UXMath
{

	// float types
	typedef half_t					float16;
	typedef half_t					half;

#if 1
	typedef float					float32;
	typedef double					float64;
#else
	typedef float32_t				float32;
	typedef float64_t				float64;
#endif

	// Real
#if UX_REAL_TYPE_SIZE == 16
	typedef float16					real;
#elif UX_REAL_TYPE_SIZE == 64
	typedef float64					real;
#else
	typedef float32					real;
#	undef UX_REAL_TYPE_SIZE
#	define UX_REAL_TYPE_SIZE	32
#endif



	// Vector
	template <typename T, usize I>	struct TVec;

	// Vec1
	typedef TVec< float32,   1 >	fvec1;
	typedef TVec< float64,   1 >	dvec1;
	typedef	TVec< int8,		 1 >	i8_vec1;
	typedef	TVec< int16,	 1 >	i16_vec1;
	typedef TVec< int32,	 1 >	i32_vec1;
	typedef TVec< int64,	 1 >	i64_vec1;
	typedef	TVec< uint8,	 1 >	u8_vec1;
	typedef	TVec< uint16,	 1 >	u16_vec1;
	typedef TVec< uint32,	 1 >	u32_vec1;
	typedef TVec< uint64,	 1 >	u64_vec1;
	typedef	TVec< int,		 1 >	ivec1;
	typedef	TVec< uint,		 1 >	uvec1;
	typedef TVec< usize,	 1 >	svec1;
	typedef TVec< int64,	 1 >	lvec1;
	typedef TVec< bool,		 1 >	bvec1;
	typedef TVec< half,		 1 >	hvec1;
	typedef TVec< fixed_t,	 1 >	xvec1;
	typedef TVec< real,      1 >	vec1;


	// Vec2
	typedef TVec< float32,	 2 >	fvec2;
	typedef TVec< float64,	 2 >	dvec2;
	typedef	TVec< int8,		 2 >	i8_vec2;
	typedef	TVec< int16,	 2 >	i16_vec2;
	typedef TVec< int32,	 2 >	i32_vec2;
	typedef TVec< int64,	 2 >	i64_vec2;
	typedef	TVec< uint8,	 2 >	u8_vec2;
	typedef	TVec< uint16,	 2 >	u16_vec2;
	typedef TVec< uint32,	 2 >	u32_vec2;
	typedef TVec< uint64,	 2 >	u64_vec2;
	typedef	TVec< int,		 2 >	ivec2;
	typedef	TVec< uint,		 2 >	uvec2;
	typedef TVec< usize,	 2 >	svec2;
	typedef TVec< int64,	 2 >	lvec2;
	typedef TVec< bool,		 2 >	bvec2;
	typedef TVec< half,		 2 >	hvec2;
	typedef TVec< fixed_t,	 2 >	xvec2;
	typedef TVec< real,		 2 >	vec2;


	// Vec3
	typedef TVec< float32,	 3 >	fvec3;
	typedef TVec< float64,	 3 >	dvec3;
	typedef	TVec< int8,		 3 >	i8_vec3;
	typedef	TVec< int16,	 3 >	i16_vec3;
	typedef TVec< int32,	 3 >	i32_vec3;
	typedef TVec< int64,	 3 >	i64_vec3;
	typedef	TVec< uint8,	 3 >	u8_vec3;
	typedef	TVec< uint16,	 3 >	u16_vec3;
	typedef TVec< uint32,	 3 >	u32_vec3;
	typedef TVec< uint64,	 3 >	u64_vec3;
	typedef	TVec< int,		 3 >	ivec3;
	typedef	TVec< uint,		 3 >	uvec3;
	typedef TVec< usize,	 3 >	svec3;
	typedef TVec< int64,	 3 >	lvec3;
	typedef TVec< bool,		 3 >	bvec3;
	typedef TVec< half,		 3 >	hvec3;
	typedef TVec< fixed_t,	 3 >	xvec3;
	typedef TVec< real,		 3 >	vec3;


	// Vec4
	typedef TVec< float32,	 4 >	fvec4;
	typedef TVec< float64,	 4 >	dvec4;
	typedef	TVec< int8,		 4 >	i8_vec4;
	typedef	TVec< int16,	 4 >	i16_vec4;
	typedef TVec< int32,	 4 >	i32_vec4;
	typedef TVec< int64,	 4 >	i64_vec4;
	typedef	TVec< uint8,	 4 >	u8_vec4;
	typedef	TVec< uint16,	 4 >	u16_vec4;
	typedef TVec< uint32,	 4 >	u32_vec4;
	typedef TVec< uint64,	 4 >	u64_vec4;
	typedef	TVec< int,		 4 >	ivec4;
	typedef	TVec< uint,		 4 >	uvec4;
	typedef TVec< usize,	 4 >	svec4;
	typedef TVec< int64,	 4 >	lvec4;
	typedef TVec< bool,		 4 >	bvec4;
	typedef TVec< half,		 4 >	hvec4;
	typedef TVec< fixed_t,	 4 >	xvec4;
	typedef TVec< real,		 4 >	vec4;


	// Color
	struct color4u;
	struct color4f;
	

	// Matrix
	template <typename T, usize C, usize R>	struct TMatrix;

	// Matrix2x2
	typedef TMatrix< float16,	2, 2 >	hmat2x2;
	typedef TMatrix< float32,	2, 2 >	fmat2x2;
	typedef TMatrix< float64,	2, 2 >	dmat2x2;
	typedef TMatrix< real,		2, 2 >	mat2x2;
	typedef mat2x2						mat2;
	typedef hmat2x2						hmat2;
	typedef fmat2x2						fmat2;
	typedef dmat2x2						dmat2;
	

	// Matrix2x3
	typedef TMatrix< float16,	2, 3 >	hmat2x3;
	typedef TMatrix< float32,	2, 3 >	fmat2x3;
	typedef TMatrix< float64,	2, 3 >	dmat2x3;
	typedef TMatrix< real,		2, 3 >	mat2x3;
	

	// Matrix2x4
	typedef TMatrix< float16,	2, 4 >	hmat2x4;
	typedef TMatrix< float32,	2, 4 >	fmat2x4;
	typedef TMatrix< float64,	2, 4 >	dmat2x4;
	typedef TMatrix< real,		2, 4 >	mat2x4;


	// Matrix3x2
	typedef TMatrix< float16,	3, 2 >	hmat3x2;
	typedef TMatrix< float32,	3, 2 >	fmat3x2;
	typedef TMatrix< float64,	3, 2 >	dmat3x2;
	typedef TMatrix< real,		3, 2 >	mat3x2;


	// Matrix3x3
	typedef TMatrix< float16,	3, 3 >	hmat3x3;
	typedef TMatrix< float32,	3, 3 >	fmat3x3;
	typedef TMatrix< float64,	3, 3 >	dmat3x3;
	typedef TMatrix< real,		3, 3 >	mat3x3;
	typedef mat3x3						mat3;
	typedef hmat3x3						hmat3;
	typedef fmat3x3						fmat3;
	typedef dmat3x3						dmat3;
	

	// Matrix3x4
	typedef TMatrix< float16,	2, 2 >	hmat3x4;
	typedef TMatrix< float32,	3, 4 >	fmat3x4;
	typedef TMatrix< float64,	3, 4 >	dmat3x4;
	typedef TMatrix< real,		3, 4 >	mat3x4;
	

	// Matrix4x2
	typedef TMatrix< float16,	4, 2 >	hmat4x2;
	typedef TMatrix< float32,	4, 2 >	fmat4x2;
	typedef TMatrix< float64,	4, 2 >	dmat4x2;
	typedef TMatrix< real,		4, 2 >	mat4x2;


	// Matrix4x3
	typedef TMatrix< float16,	4, 3 >	hmat4x3;
	typedef TMatrix< float32,	4, 3 >	fmat4x3;
	typedef TMatrix< float64,	4, 3 >	dmat4x3;
	typedef TMatrix< real,		4, 3 >	mat4x3;


	// Matrix4x4
	typedef TMatrix< float16,	4, 4 >	hmat4x4;
	typedef TMatrix< float32,	4, 4 >	fmat4x4;
	typedef TMatrix< float64,	4, 4 >	dmat4x4;
	typedef TMatrix< real,		4, 4 >	mat4x4;
	typedef mat4x4						mat4;
	typedef hmat4x4						hmat4;
	typedef fmat4x4						fmat4;
	typedef dmat4x4						dmat4;


	// Rect
	template <typename T> struct TRect;

	typedef TRect< float16 >		hrect;
	typedef TRect< float32 >		frect;
	typedef TRect< float64 >		drect;
	typedef TRect< int8    >		i8_rect;
	typedef TRect< int16   >		i16_rect;
	typedef TRect< int32   >		i32_rect;
	typedef TRect< int64   >		i64_rect;
	typedef TRect< uint8   >		u8_rect;
	typedef TRect< uint16  >		u16_rect;
	typedef TRect< uint32  >		u32_rect;
	typedef TRect< uint64  >		u64_rect;
	typedef TRect< int     >		irect;
	typedef TRect< uint    >		urect;
	typedef TRect< usize   >		srect;
	typedef TRect< int64   >		lrect;
	typedef TRect< real    >		rect;


	// Line
	template <typename VecType> struct TLine;

	typedef TLine< hvec2 >		hline2d;
	typedef TLine< fvec2 >		fline2d;
	typedef TLine< dvec2 >		dline2d;
	typedef TLine< vec2 >		line2d;
	
	typedef TLine< hvec3 >		hline3d;
	typedef TLine< fvec3 >		fline3d;
	typedef TLine< dvec3 >		dline3d;
	typedef TLine< vec3 >		line3d;


	// Quaternion
	template <typename T> struct TQuaternion;

	typedef TQuaternion< float16 >		hquat;
	typedef TQuaternion< float32 >		fquat;
	typedef TQuaternion< float64 >		dquat;
	typedef TQuaternion< real >			quat;

//-------------------------------------------------------------------

}	// UXMath
}	// UX_STL

#endif	// _UXS_MATH_TYPES_H